package org.lee.other.util;

import com.google.gson.GsonBuilder;

/**
 * JsonUtil
 *
 * @author dralee
 * @date 2022-01-20 11:04:29
 **/
public class JsonUtil {
    private static GsonBuilder builder;

    static {
        builder = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss");
    }

    public static String toJson(Object obj) {
        return builder.create().toJson(obj);
    }

    public static <T> T fromJson(String json, Class<T> clazz) {
        return builder.create().fromJson(json, clazz);
    }
}
